Optional Sprites.f

Requires Structs
Requires Tools
Requires Quicksort
Requires SORA\Blocks
Requires SORA\Motifs
Requires SORA\Vertices
Requires SORA\Vbufs

Only Forth Definitions

icode xswap
   0 [ebp] ecx mov
   8 [ebp] eax mov
   ecx 8 [ebp] mov
   eax 0 [ebp] mov
   ret end-code

icode yswap
   ebx ecx mov
   4 [ebp] ebx mov
   ecx 4 [ebp] mov
   ret end-code


0 Value (flip)
: flip-00      dup >r 2h@  r> 4 + 2h@ 2over 2+ ;
: flip-10      flip-00 xswap ;
: flip-01      flip-00 yswap ;
: flip-11      flip-00 2swap ;
create flips   ' flip-00 , ' flip-10 , ' flip-01 , ' flip-11 ,

: slow-sprite  ( subimage transform -- )
   locals| t spr  |
   spr (flip) cells flips + @ execute
   t ->z @
   spr 8 + h@ negate
   spr 10 + h@ negate  t 2transform
   spr 4 + 2h@ t 2transform 2over 2+
   quad2d ;

: fast-sprite  ( subimage transform -- )
   locals| t spr |
   spr 2h@
   spr 4 + 2h@ 2over 2+
   t ->z @
   t ->x 2v@   spr 8 + 2h@ 2-   spr 4 + 2h@ 2over 2+
   quad2d ;

: sprite  ( subimage transform -- )
   dup ->color @ rgba  ->roll @   (flip) or if slow-sprite else fast-sprite then ;

